<template>
  <el-dialog
    title="周报信息编辑"
    :close-on-click-modal="false" width="60%"
    :append-to-body="true"
    :visible.sync="weekRportVisible">
    <el-form :model="weekRportForm" :rules="dataRule" ref="weekRportForm" label-width="120px">
      <el-col :span="24">
        <el-form-item label="问题标题" prop="wtbt">
          <el-input v-model="weekRportForm.wtbt" :disabled="disabled" :maxlength="100" placeholder="问题标题">
          </el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="问题专题" prop="wtztYf">
          <el-dict code="XTZT_LIST" v-model="weekRportForm.wtztYf" placeholder="问题专题" clearable filterable
                   :disabled="disabled"></el-dict>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="问题简述" prop="wtjsJf">
          <el-input v-model="weekRportForm.wtjsJf" :disabled="disabled" type="textarea" :rows="5" :maxlength="300"
                    placeholder="对问题详述内容进行概要描述（用于生成周报以及放入常见问题），如：新电局调用税撑XXXX关联关系，返给电子税局的报文字段XX，多次调用结果不一致"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="问题分析" prop="sjfxjg">
          <el-input v-model="weekRportForm.sjfxjg" type="textarea" :rows="5" :maxlength="500" :disabled="disabled"
                    placeholder="问题分析（用于生成周报以及放入常见问题），描述该业务的前后业务逻辑，如何实现等等"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="解决方案" prop="jjfaJf">
          <el-input v-model="weekRportForm.jjfaJf" :disabled="disabled" type="textarea" :rows="5" :maxlength="500"
                    placeholder="解决方案（用于生成周报以及放入常见问题），如：临时方案调整应用程序中XXX配置后重启XXX应用，彻底解决方案需对应用程序进行修改等"></el-input>
        </el-form-item>
      </el-col>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="weekRportVisible = false">取消</el-button>
      <el-button v-if="!disabled" type="primary" @click="weekRportFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      disabled: false,
      weekRportVisible: false,
      weekRportForm: {
        wtdh: '',
        wtbt: '',
        wtztYf: '',
        sjfxjg: '',
        jjfaJf: '',
        wtjsJf: ''
      },
      dataRule: {
        wtbt: [
          {required: true, message: '问题标题不能为空', trigger: 'blur'}
        ],
        wtztYf: [
          {required: true, message: '问题专题', trigger: 'blur'}
        ],
        sjfxjg: [
          {required: true, message: '问题分析不能为空', trigger: 'blur'}
        ],
        jjfaJf: [
          {required: true, message: '解决方案不能为空', trigger: 'blur'}
        ],
        wtjsJf: [
          {required: true, message: '问题简述不能为空', trigger: 'blur'}
        ]
      }
    }
  },
  methods: {
    init(dywtxx) {
      this.weekRportVisible = true
      this.$nextTick(() => {
        this.$refs['weekRportForm'].resetFields()
        this.weekRportForm.wtdh = dywtxx.wtdh
        this.weekRportForm.wtbt = dywtxx.wtbt
        this.weekRportForm.wtztYf = dywtxx.wtztYf
        this.weekRportForm.sjfxjg = dywtxx.sjfxjg
        this.weekRportForm.jjfaJf = dywtxx.jjfaJf
        this.weekRportForm.wtjsJf = dywtxx.wtjsJf
      })
    },
    weekRportFormSubmit() {
      this.$refs['weekRportForm']
        .validate((valid) => {
          if (valid) {
            this.$http({
              url: `/zr/dytz/saveWeekReport`,
              method: 'post',
              data: this.weekRportForm
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功,操作问题单号：' + this.weekRportForm.wtdh,
                  type: 'success',
                  duration: 3500
                })
                this.weekRportVisible = false
                this.$emit('weekreportBack')
              }
            })
          }
        })
    }
  }
}
</script>

<style scoped>

</style>
